<template>
  <div id="register">
    <div id="top">
      <span class="iconfont arrow_l">&#xe6bc;</span>
      <h2>手机登录</h2>
      <p>
        <span class="iconfont">&#xf0112;</span>
        <span class="iconfont">&#xe71e;</span>
        <i class="line"></i>
      </p>
    </div>
    <!-- 主体 -->
    <main>
      <div class="wrap">
        <img src="../assets/images/页面-9-手机登录_03.png" alt="" />
        <p class="box1">
          <span>手机号</span>
          <input type="text" name="" id="" v-model="form.phone" />
        </p>
        <p class="box2">
          <span>昵称</span>
          <input type="text" name="" id="" v-model="form.nickname" />
        </p>
        <p class="box2">
          <span>密码</span>
          <input type="password" name="" id="" v-model="form.password" />
        </p>
        <p  class="but" @click="adduser">注册</p>
      </div>
    </main>

    <footer></footer>
  </div>
</template>

<script>
import {register} from '../utils/api'
export default {
    data(){
      return{
        form:{
          phone:"",
          nickname:"",
          password:""
        }
      }
    },
    methods:{
       adduser(){
         if(this.form.phone!=""&&this.form.nickname!=""&&this.form.password!=""){
           register(this.form).then(res=>{
             if(res.data.code==200){
               alert("注册成功，5S后即将跳转")
               setTimeout(function(){
               location.href="/login"
              },5000)
             }else{
                 alert(res.data.msg)
             }
           })
         }else{
           alert("有内容为空，请写入")
         }
       }
    }
}
</script>

<style >
 /*头部*/
#top {
  height: 0.64rem;
  padding: 0.28rem 0.1rem 0.28rem 0.33rem;
  background-color: #ff6040;
  display: flex;
  color: #ffdfd8;
  justify-content: space-between;
  align-items: center;
}
#top .arrow_l {
  font-size: 0.34rem;
}
#top h2 {
  font-size: 0.32rem;
  margin-left: 1rem;
}
#top p {
  height: 0.64rem;
  width: 1.75rem;
  display: flex;
  border: 1px solid #ff8a6f;
  box-sizing: border-box;
  border-radius: 0.64rem;
  align-items: center;
  position: relative;
}
#top p span {
  width: 50%;
  height: 100%;
  text-align: center;
  line-height: 0.64rem;
}
#top p .line {
  width: 1px;
  height: 0.38rem;
  position: absolute;
  left: 0.87rem;
  top: 0.13rem;
  background-color: #fff;
}
main {
  padding: 0.2rem 0.2rem 0.86rem;
  box-sizing: border-box;
}
main .wrap {
  height: 13.4rem;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
}
main .wrap img {
  width: 3.7rem;
  margin-top: 4.8rem;
}
main .wrap p {
  height: 0.46rem;
  width: 6.06rem;
  border-bottom: 1px solid #f7f7f7;
}
main .wrap p.box1 {
  margin-top: 1.15rem;
}
main .wrap p.box1 span {
  font-size: 0.24rem;
  color: #6a6a6a;
  width: 1rem;
  display: inline-block;
}
main .wrap p.box1 input {
  height: 0.46rem;
  width: 3.7rem;
  border: none;
}
main .wrap p.box2 {
  height: 0.78rem;
  display: flex;
  align-items: center;
}
main .wrap p.box2 span {
  font-size: 0.24rem;
  color: #6a6a6a;
   width: 1rem;
}
main .wrap p.box2 input {
  height: 0.46rem;
  width: 4.7rem;
  border: none;
  border-left-color: red;
}

main .wrap .but {
  width: 6.06rem;
  height: 0.98rem;
  background-color: #cccccc;
  color: #fff;
  text-align: center;
  line-height: 0.98rem;
  font-size: 0.3rem;
  margin-top: 0.4rem;
}
footer {
  width: 2.68rem;
  height: 0.1rem;
  position: fixed;
  bottom: 0.18rem;
  left: 33.3%;
  background-color: #000;
  border-radius: 0.05rem;
}

</style>